package com.ajun.listener.direct;

import com.ajun.common.rabbit.QueueConstants;
import com.ajun.service.SmsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * Sms RabbitMQ 消费者
 *
 * @author AJun
 * @date 2021-07-14
 */
@Slf4j
@Component
@RabbitListener(queues = {QueueConstants.SMS_DIRECT_QUEUE})
public class DirectSmsListener {

    @Resource
    private SmsService smsService;

    @RabbitHandler
    public void recvMessage(String message) {
        log.info("Sms 接收到订单信息(direct),orderId => {}", message);
        // 发送 Sms 给用户
        log.info(smsService.sendSms("1", message));
    }
}
